function rules = BestForClassRules( InitData, dataSample, Antecedents, Params)

  [allRules , fulfilments] = AllRules( InitData, dataSample,...
    Antecedents, Params);
  
  InitData.RullesCount = min( ceil(InitData.RullesCount / InitData.ClassCount) ,...
    size(allRules,1));
  InitData.FeatureCount =  InitData.FeatureCount + 1;
  
  rules = zeros(InitData.RullesCount,  InitData.FeatureCount);  
  
  for i=1:InitData.ClassCount
    
    indices = find(allRules(:,InitData.FeatureCount) == i);
    count = min(size(indices,1),InitData.RullesCount);
    
    for j = 1:count
      [~,index] = max(fulfilments(indices));
      rules((i-1)*count + j,:) = allRules(indices(index),:);
      indices(index) = [];
    end%for j
  end%for i
  
  %kill zero rows
  rules(~any(rules,2),:) = [];  
end

